
import sys
from PySide2.QtWidgets import QApplication, QMessageBox, QLineEdit, QMainWindow
from PySide2.QtUiTools import QUiLoader
from client_window_ui import Ui_MainWindow


class LoginGUI:
    def __init__(self):
        self.ui = QUiLoader().load('demo.ui')
        self.ui.btnLogin.clicked.connect(self.btnLogin_clicked)

    def btnLogin_clicked(self):
        if self.ui.txtUser.text() == "Root" and self.ui.txtPWD.text() == "pyside2":
            QMessageBox.about(self.ui, 'Login result', 'login successed')
        else:
            QMessageBox.about(self.ui, 'Login result', 'login failed')


class MainWindow(QMainWindow):
    def __init__(self, parent = None):
        QMainWindow.__init__(self, parent)
        self.setupUi()

    def setupUi(self):
        #   加载示例Demo主页
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.toolBar.addAction(self.ui.actionCopy)
        self.ui.toolBar.addSeparator()
        self.ui.txtAddr = QLineEdit(self)
        self.ui.toolBar.addWidget(self.ui.txtAddr)
        self.ui.toolBar.addAction(self.ui.actionReconnect)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addAction(self.ui.actionOptions)
        self.ui.toolBar.addAction(self.ui.actionWhatIsThis)
        self.ui.defaultTab.layout().addWidget(QUiLoader().load('demo.ui'))

        #self.ui.defaultTab.setLay

def main():
    app = QApplication(sys.argv)
    mainwindow = MainWindow()
    mainwindow.show()
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()
    #app = QApplication([])
    #QMessageBox.about(None, 'qq', 'aa')
    #gui = LoginGUI()
    #gui.ui.show()
    #app.exec_()
